package Chapter6;

//127页例6.10 多态
class SuperClass1 { //父类
    public void method() {
        System.out.println("调用父类方法！");
    }
}

class SubClass1 extends SuperClass1 { //子类继承父类 重写方法
    public void method() {
        System.out.println("调用子类方法！");
    }
}

public class Polymorphism {
    public static void main(String[] args) {
        SuperClass1 superC = new SuperClass1();
        SubClass1 subC = new SubClass1();
        SuperClass1 ssc= new SubClass1();
        superC.method();
        subC.method();
        ssc.method();
    }
}